##
#                  ,           /)   
#   _   _ __  _/_   __    _  _(/  _ 
#  (___(/_/ (_(___(_/_)__(/_(_(__(/_
#                .-/                
#               (_/     
#
#  http://code.google.com/p/centipede/
#  Understanding & simplicity
#  Copyright 2009, Asbjorn Enge. All rights reserved.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
#  MA  02111-1307  USA
#
#  (C) 2010
#
##
#
#  Controllers
#
##

from urlrelay import URLRelay
from static import Cling

from framework import expose, template, _static_path

## Expose the controllers
#

@expose('^/$','GET')
def index(request, response):
    """ Return the index template
    """
    return template('index.html')
    
@expose('^/poem$','POST')
def index(request, response):
    """ Return the poem template
    """
    answer = False
    if request.params.has_key('question'):
        answer = request.params['question'] == 'yes' and True or False
    
    
    poem = """
        Centipede dabble above slippery claims,<br/>
        it's peglegs can roundtrip confusable frames.<br/><br/>
        
        asbjornenge@2010<br/>
        enjoy.
    """

    if not answer:
        poem = """
            Well, if you can't appreciate a poem...
        """
        
    return template('poem.html', poem=poem)
    
## Make the application
#

def make_app():
    static_app = Cling(_static_path)
    app = URLRelay(default=static_app)
    return app
